package com.jungle.sp.daily.feature.d4_unnamed_patterns_and_variables;

/**
 * @author Jungle
 * @create 2024-07-14 7:25
 */
public class Demo {
    public static void main(String[] args) {
        int[] orderIds = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
        int total = 0;
        for (int _ : orderIds) {
            total++;
        }
        // System.out.println(total);


    //     未命名模式
        double distance = getDistance(new ColoredPoint(new Point(1, 1), Color.RED), new ColoredPoint(new Point(2, 2), Color.RED));
        System.out.printf("%.2f%n",distance);

    }

    public static double getDistance(Object obj1, Object obj2) {
        if (obj1  instanceof ColoredPoint(Point p, _)&&obj2 instanceof ColoredPoint(Point p2, _)) {

            return Math.sqrt(Math.pow(p.x()-p2.x(), 2) + Math.pow(p.y()-p2.y(), 2));
        }else {
            return -1d;
        }
    }
}
